Skip to content

Conversation

@mredolatti
Copy link
Contributor

No description provided.

Copy link
Contributor

@patricioe patricioe left a comment

Choose a reason for hiding this comment

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

Reminder to update the CHANGES file with its description

private final Cache<Long, Long> _cache;

public ImpressionObserver(long size) {
_cache = CacheBuilder.newBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to set the concurrency level?

Copy link
Contributor

Choose a reason for hiding this comment

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

how about the expiration settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding cuncurrency level: the cache is only used from the impressions manager which is executed within a singleThreadedExecutor, so we should not have race conditions here, nor benefit from partitioning to minimize contention. I can however set the default value (4) explicitly, in case it changes sometime, or we decide to go multithreaded here

Regarding expiration settings: We discussed this thoroughly with nico, and in order to minimize memory usage, we decided not to attach an extra TTL to each cache item, since the difference between sending null or sending an old timestamp doesn't really make a difference. We let the events server decide whether the timestamp is recent enough to filter the impression from the exp pipeline or not


Long hash = ImpressionHasher.process(impression);

synchronized(this) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this can't be here. It'll be too slow. Better to use the compute method from guava cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the caller is single thread correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not familiar with compute method, i'll look into it.
It's single threaded, but I added the synchronized block, in order to avoid surprises in the future, are those statements really that slow? the hashing computation is done outside of the critical region

patricioe
patricioe previously approved these changes Jul 9, 2020
@mredolatti mredolatti changed the base branch from master to development July 9, 2020 22:13
@mredolatti mredolatti merged commit c188ea1 into development Jul 15, 2020
@mmelograno mmelograno deleted the improvement/impressionSeenAt branch February 22, 2022 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants