Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewriting the queue #78

Merged
merged 107 commits into from
Aug 4, 2024
Merged

Rewriting the queue #78

merged 107 commits into from
Aug 4, 2024

Conversation

CorentinB
Copy link
Collaborator

@CorentinB CorentinB commented Jul 12, 2024

The goal of this work is to replace the current queuing mechanism that use github.com/beeker1121/goque with a custom piece of code that exactly fit our needs and on which we will have much better control.

Almost all queuing components have been rewritten except the host crawl rate limiter, I commented out the relevant parts with // TODO: re-implement host limitation, @NGTmeaty if you can look into that part as you were the original author, to make it fit in the current design, it would be nice. Having it as a separate package would also be great.

I also separated the queue and seencheck packages, instead of having 1 big "frontier" package. FWIW, I'm also moving away calling it "frontier", it has only caused misunderstanding from the people I explained it too. (it was originally named like that to follow Heritrix3 path.. but let's clean things up and not use that term anymore)

Finally, I added a big list of statistics and infos about the queue that are available through the API at /queue.

Suggestions & code-review are welcome and well-needed. :)

@CorentinB CorentinB added the enhancement New feature or request label Jul 12, 2024
@CorentinB CorentinB requested review from NGTmeaty and equals215 July 12, 2024 10:50
@CorentinB CorentinB self-assigned this Jul 12, 2024
@CorentinB CorentinB marked this pull request as ready for review July 12, 2024 12:15
equals215
equals215 previously approved these changes Jul 12, 2024
Copy link
Member

@equals215 equals215 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, comments are mostly suggestions
good job Coco it looks really nice 😊

(i'm already crying blood from thinking I'll need to merge this to my stale PR)

internal/pkg/crawl/crawl.go Outdated Show resolved Hide resolved
internal/pkg/crawl/crawl.go Outdated Show resolved Hide resolved
internal/pkg/queue/dequeue.go Outdated Show resolved Hide resolved
internal/pkg/queue/dequeue_test.go Outdated Show resolved Hide resolved
internal/pkg/queue/enqueue.go Show resolved Hide resolved
}

// If we've checked all hosts and found no items, loop back to wait again
return q.Dequeue()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you really sure you wanna go down the recursive path? what happens if a function calls Dequeue() when the queue is empty and mistakenly stackoverflow?

@equals215
Copy link
Member

aligned queue structures to save space

Zeno/internal/pkg/queue/metadata.go:17:15: 16 bytes saved: struct with 224 pointer bytes could be 208
Zeno/internal/pkg/queue/metadata.go:63:14: 16 bytes saved: struct with 224 pointer bytes could be 208
Zeno/internal/pkg/queue/queue.go:30:29: 80 bytes saved: struct with 360 pointer bytes could be 280
Zeno/internal/pkg/queue/queue.go:52:11: 32 bytes saved: struct with 104 pointer bytes could be 72
Zeno/internal/pkg/queue/stats.go:8:17: 64 bytes saved: struct with 184 pointer bytes could be 120

NGTmeaty and others added 4 commits July 16, 2024 00:49
Prometheus was always expecting to be there but API is not always set when crawls are ran. This resolves that issue.
equals215 and others added 12 commits August 1, 2024 19:44
make handover optional
added lastAction on API worker state to troubleshoot
made the default HQ batches smaller
made handover hold the whole batch before enqueuing on disk
handover now has an automatic closing mechanism that adapts to activity so the handover get closed and drained on disk if no workers need it
for enabling FireFox's json preview
@yzqzss
Copy link
Contributor

yzqzss commented Aug 3, 2024

@equals215

image

time=xxxxxxxxx level=WARN msg="[WORKERS] Timeout reached. 2 workers still running"

7029d7e
6a34cac

Workers get stuck in the second inner for.
revert to if statement?

@CorentinB
Copy link
Collaborator Author

@yzqzss I think --batch-write-WAL should be --batch-write-wal, but any occurence of WAL in the code in variables (such as walPath for example) should be capitalized. (as per Go variable naming convention)

@yzqzss
Copy link
Contributor

yzqzss commented Aug 4, 2024

@yzqzss I think --batch-write-WAL should be --batch-write-wal, but any occurence of WAL in the code in variables (such as walPath for example) should be capitalized. (as per Go variable naming convention)

yeap, I think WalIoPercent is a bit stupid too. feel free to change them yourself. :)

@equals215 equals215 merged commit 53dd830 into main Aug 4, 2024
1 check failed
@equals215
Copy link
Member

finally!

@equals215 equals215 deleted the queue branch August 4, 2024 18:36
@@ -37,6 +27,8 @@ type PersistentGroupedQueue struct {
mutex sync.RWMutex
statsMutex sync.RWMutex
closed bool

logger *slog.Logger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger has not been initialized 😱

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internal-only This PR/Issue is reserved for the IA team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants