Skip to content

speedup context injection matchers#1261

Merged
mar-kolya merged 3 commits into
masterfrom
mar-kolya/speedup-context-injection-matchers
Feb 28, 2020
Merged

speedup context injection matchers#1261
mar-kolya merged 3 commits into
masterfrom
mar-kolya/speedup-context-injection-matchers

Conversation

@mar-kolya
Copy link
Copy Markdown
Contributor

@mar-kolya mar-kolya commented Feb 27, 2020

This provides 0.5-1s speedup on petclinic app on java8.

There is still a question on how to make different classloader matchers not break things - but even in current state this should be functionally correct.

@mar-kolya mar-kolya force-pushed the mar-kolya/speedup-context-injection-matchers branch from 1a69726 to 2cf9798 Compare February 27, 2020 10:08
@mar-kolya mar-kolya changed the title Mar kolya/speedup context injection matchers speedup context injection matchers Feb 27, 2020
@mar-kolya mar-kolya requested a review from a team February 27, 2020 10:47
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, that assumption sounds reasonable to me, but I think it speaks to the fact that our abstraction isn't quite right.

It seems to me that the contextClasses should carry a ClassLoaderMatcher constraint that is incorporated into the Instrumenter activation implicitly. An Instrumenter could safely add additional criteria, but cannot remove the requirement needed by the contextClasses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, our abstractions are wrong and I'm not immediately sure how to fix that. I think we have to introduce the notion of 'compound instrumenter' - i.e. 'instrumenter' that covers multiple instances of Instrumenter.Default and defines common settings for them.

Currently we do not have this mechanism.

Copy link
Copy Markdown
Contributor

@richardstartin richardstartin Sep 24, 2020

Choose a reason for hiding this comment

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

We ended up disabling field injection of Runnables and Callables when classloader matchers were added for AkkaForkJoinPool and ScalaForkJoinPool because they share context stores with the RunnableInstrumentation and CallableInstrumentation - see #1910

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

interesting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A Set<Map.Entry<String, String>> looks rather odd. My first thought was how this different from a Setof just the Entry keys. But I guess we're accumulating this from multiple maps, so it makes sense. Still not very obvious.

I also think there's likely a better option than reducing statics here. Ultimately, the reset boundary is contained by the caller, so I think it would be better for the caller to construct and pass in object rather than introducing a static that the caller must remember to reset.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do not have a strong opinion here overall, but I feel passing it from 'outside' has two problems:

  • We spread way to much internal knowledge outside
  • We would pipe it through quite a few levels

Overall I'm not sure it's worth the effort. Proper fix here is to fix our abstraction (with compound instrumenter of something) so we do not have to resort to this hack. But as far as hack goes I do not think that passing set all over the place is much better than using static.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For me, the need to have the caller call reset is spreading the outside knowledge.

But I think this is fine for now, I think we agree the real issue is that we're missing a concept that connects multiple related Instrumenters. But I don't think, we should try to fix that in this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this wasn't part of this change, but I think we might be well served to move the construction of this Matcher into a helper method. Doesn't need to be part of this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm actually questioning correctness of this matcher at all - i have a feeling we should not put it here at all

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll look into this as separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mar-kolya mar-kolya force-pushed the mar-kolya/speedup-context-injection-matchers branch 2 times, most recently from 9b711c9 to 3723b4f Compare February 27, 2020 15:22
@mar-kolya mar-kolya force-pushed the mar-kolya/speedup-context-injection-matchers branch from 3723b4f to d53c138 Compare February 27, 2020 15:26
@mar-kolya mar-kolya marked this pull request as ready for review February 27, 2020 15:46
@dougqh
Copy link
Copy Markdown
Contributor

dougqh commented Feb 27, 2020

While performing a perf integration test, I accidentally merged this prematurely to master. Since this has passed reviews, we should resolve the conflicts and get this merged through the normal means.

@mar-kolya mar-kolya force-pushed the mar-kolya/speedup-context-injection-matchers branch from 538987b to cf5fe9f Compare February 28, 2020 01:07
@mar-kolya mar-kolya merged commit a26f089 into master Feb 28, 2020
@mar-kolya mar-kolya deleted the mar-kolya/speedup-context-injection-matchers branch February 28, 2020 02:04
@tylerbenson tylerbenson added this to the 0.45.0 milestone Mar 2, 2020
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.

4 participants