Skip to content

UOE-8632: refactor URL macro replacer to reduce mem allocs #419

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

Open
wants to merge 6 commits into
base: ci_backup_20240824
Choose a base branch
from

Conversation

pm-nilesh-chate
Copy link
Collaborator

Description

Please add change description or link to ticket, docs, etc.

Checklist:

  • PR commit list is unique (rebase/pull with the origin branch to keep master clean).
  • JIRA number is added in the PR title and the commit message.
  • Updated the header-bidding repo with appropiate commit id.
  • Documented the new changes.

For Prebid upgrade, refer: https://inside.pubmatic.com:8443/confluence/display/Products/Prebid-server+upgrade

@pm-nilesh-chate pm-nilesh-chate changed the title Uoe 8632 ci 1 UOE-8632: refactor URL macro replacer to reduce mem allocs Jan 19, 2023
@pm-nilesh-chate pm-nilesh-chate marked this pull request as ready for review January 19, 2023 04:21
@pm-nilesh-chate pm-nilesh-chate changed the base branch from ci_backup_20230508 to ci September 1, 2023 07:18
func replaceMacro(trackerURL, macro, value string) string {
macro = strings.TrimSpace(macro)
trimmedValue := strings.TrimSpace(value)
func replaceMacros(trackerURL string, macroMap map[string]string) string {
Copy link
Collaborator

@Pubmatic-Dhruv-Sonone Pubmatic-Dhruv-Sonone Sep 1, 2023

Choose a reason for hiding this comment

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

Can you try using Macro Replacer from macros package and check if we get similar benchmark result?

pm-viral-vala
pm-viral-vala previously approved these changes Sep 1, 2023
trackingEle.CreateAttr("event", event)
trackingEle.SetText(fmt.Sprintf("%s", url))
trackingEle.SetText(eventURLMap[event])
Copy link
Collaborator

@Pubmatic-Dhruv-Sonone Pubmatic-Dhruv-Sonone Sep 1, 2023

Choose a reason for hiding this comment

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

I think this needs to be CData instead of plain text.

eventURL = replaceMacro(eventURL, PBSAccountMacro, req.Site.Publisher.ID)
}

if req != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this check even required at this stage?

err := json.Unmarshal(req.Ext, &reqExt)
if err == nil {
customMacroMap = reqExt.Prebid.Macros
// replace standard macros
Copy link
Collaborator

@Pubmatic-Dhruv-Sonone Pubmatic-Dhruv-Sonone Sep 1, 2023

Choose a reason for hiding this comment

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

Request Level macro remain constant for all the tracker. Can we populate this only once?

Comment on lines +198 to +203
// lookup in custom macros - keep this block at last for highest priority
reqExt := new(openrtb_ext.ExtRequest)
if req.Ext != nil {
err := json.Unmarshal(req.Ext, &reqExt)
if err != nil {
glog.Warningf("Error in unmarshling req.Ext.Prebid.Vast: [%s]", err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we get access to requestWrapper here, will reduce the extract unmarshling overhead?

`<VASTAdTagURI><![CDATA[%v]]></VASTAdTagURI>` +
`<Impression></Impression><Creatives></Creatives>` +
`</Wrapper></Ad></VAST>`
wrapperVASTTemplate := `<VAST version="3.0"><Ad><Wrapper><AdSystem>prebid.org wrapper</AdSystem><VASTAdTagURI><![CDATA[%v]]></VASTAdTagURI><Impression></Impression><Creatives></Creatives></Wrapper></Ad></VAST>`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let us revert formatting change. This is prebid function

@pm-nilesh-chate pm-nilesh-chate changed the base branch from ci_backup20231023 to ci July 1, 2024 11:17
@pm-nilesh-chate pm-nilesh-chate dismissed pm-viral-vala’s stale review July 1, 2024 11:17

The base branch was changed.

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